package  
{
	import fl.video.VolumeBarAccImpl;
	import flash.geom.Point;
	/**
	 * Classe de la gestion de l'I.A des caspers. hooooo....!!!!!
	 * @author anthony & oussama 
	 */
	public class Ia 
	{
		public var fontome:Fontome;
		
		public function Ia() 
		{
			
		}
		public function Ia(fnt:Fontome) {
			this.fontome = fnt;
		}
		
		//comportement
		public function compportementFontome(pacmanPos:Point) {
			var posFontome:Point = this.fontome.positionFontome;
					
			
		}
		// calcule la distance entre deux points
		public function calculDistance(position1:Point, position2:Point):Number {
			var dis1:Number = Math.pow((position1.x - position2.x), 2);
			var dis2:Number = Math.pow((position1.y - position2.y), 2);
			var distance:Number = Math.sqrt(dis1 + dis2);
			return distance;
		}
		
		// retrun la position min de pacman 
		public function valeurMin(pos1:Point, pos2:Point, pos3:Point, pos4:Point, pacmanPos:Point):Point {
			
			var posMin:Point = pos1;
			
			var numLoc:Number = calculDistance(posMin, pacmanPos);
			if (calculDistance(pos2, pacmanPos)< numLoc) 
				posMin = pos2;
			
			
			else {
				if (calculDistance(pos3, pacmanPos) < numLoc) 
				posMin = pos3;
				
					else {
						if (calculDistance(pos4, pacmanPos) < numLoc) 
							posMin = pos4;
						
					}
				
			}
			
		return posMin ;	
		}
		
		// retrun la position max de pacman 
		public function valeurMax(pos1:Point, pos2:Point, pos3:Point, pos4:Point, pacmanPos:Point):Point {
			
			var posMax:Point = pos1;
			
			var numLoc:Number = calculDistance(posMax, pacmanPos);
			if (calculDistance(pos2, pacmanPos)> numLoc) 
				posMax = pos2;
			
			
			else {
				if (calculDistance(pos3, pacmanPos) > numLoc) 
				posMax = pos3;
				
					else {
						if (calculDistance(pos4, pacmanPos) > numLoc) 
							posMax = pos4;
						
					}
				
			}
			
		return posMax ;	
		}
		}
	}

}